package 数组.数组中重复的数字;

import 链表.移除链表元素.ListNode;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author: wh(1835734390 @ qq.com)
 * @date: 2023/3/3 17:17
 * @description:
 * @version:
 */
public class Solution {
    public static void main(String[] args) {
        int[] array = {2,3,1,0,2,5,3};
        System.out.println(findRepeatNumber(array));

        List<Person> list = new ArrayList<>();
        list.add(new Person("wanghu",24));
        list.add(new Person("xzq",30));
        List<Person> personList = list.stream().filter(person -> person.getAge() > 25).collect(Collectors.toList());
        personList.get(0).setAge(40);

        List<Object> collect = list.stream().map(item -> {item.setAge(0);return item;}).collect(Collectors.toList());
        collect.add(new Person("jjjj",99));
        System.out.println();
    }

    //哈希
    public static int findRepeatNumber(int[] nums) {
        Map<Integer,Integer> map = new HashMap<>();
        for (Integer num: nums) {
            if (map.containsKey(num)){
                return  num;
            }
            map.put(num,1);
        }
        return 0;
     }





}
